package cn.kbyue.ormdemo.entity;

import cn.kbyue.ormdemo.entity.enums.GenderEnum;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author kbyue
 * @since 2023-04-12
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("orm_person")
public class Person extends Model<Person> {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @TableField(value = "username", condition = SqlCondition.LIKE)
    private String username;

    @TableField("age")
    private Integer age;

    @TableField("gender")
    private GenderEnum gender;

    @TableField("deleted")
    @TableLogic
    private Integer deleted;

    @TableField("version")
    @Version
    private Integer version;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @Override
    public Serializable pkVal() {
        return this.id;
    }
}
